home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 074 (1990-04)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 074 (1990-04)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / A68k / Operands.c < prev    next >
C/C++ Source or Header  |  1990-04-23  |  18KB  |  603 lines

  1. /*------------------------------------------------------------------*/
  2. /*                                    */
  3. /*            MC68000 Cross Assembler                */
  4. /*                                    */
  5. /*        Copyright (c) 1985 by Brian R. Anderson            */
  6. /*                                    */
  7. /*               Operand processor - November 2, 1989            */
  8. /*                                    */
  9. /*   This program may be copied for personal, non-commercial use    */
  10. /*   only, provided that the above copyright notice is included        */
  11. /*   on all copies of the source code.  Copying for any other use   */
  12. /*   without the consent of the author is prohibited.            */
  13. /*                                    */
  14. /*------------------------------------------------------------------*/
  15. /*                                    */
  16. /*        Originally published (in Modula-2) in            */
  17. /*        Dr. Dobb's Journal, April, May, and June 1986.        */
  18. /*                                    */
  19. /*     AmigaDOS conversion copyright 1989 by Charlie Gibbs.        */
  20. /*                                    */
  21. /*------------------------------------------------------------------*/
  22.  
  23. #include <stdio.h>
  24. #include "A68kdef.h"
  25. #include "A68kglb.h"
  26.  
  27. /* Functions */
  28. extern int  LineParts(), Instructions(), ObjDir();
  29. extern int  ReadSymTab(), OpenIncl(), CountNest();
  30. extern long AddrBndW(), AddrBndL(), GetValue(), CalcValue();
  31. extern char *AddName(), *GetField();
  32. extern struct SymTab *NextSym();
  33. extern struct SymTab **HashIt();
  34.  
  35. int GetArgs(), GetMultReg(), GetAReg(), IsRegister(), GetInstModeSize();
  36.  
  37.  
  38.  
  39. int GetArgs (name) char *name;
  40. /* Gets macro arguments and adds them to FNStack after adding "name".
  41.     Returns the number of arguments added to the stack.
  42.     Note that this might not be the full number of arguments
  43.     provided if the stack overflowed.                */
  44. {
  45.     register char *s, *t;
  46.     int narg, instring;
  47.     char currarg[MAXLINE];        /* Current argument */
  48.  
  49.     narg = strlen (name) + 1;
  50.     Heap2Space (narg);            /* Find space for name. */
  51.     strcpy (NextFNS, name);        /* Add name to stack. */
  52.     NextFNS += narg;            /* Bump pointer. */
  53.     if (NextFNS > High2)
  54.     High2 = NextFNS;        /* Update the high-water mark. */
  55.  
  56.     narg = 0;                /* Argument counter */
  57.  
  58.     s = Line + SrcLoc;            /* Now scan Line. */
  59.     while (!isspace(*s) && (*s != ';') && (*s != '\0')) {
  60.     t = currarg;
  61.     if (instring = (*s == '<'))    /* String delimiter */
  62.         s++;
  63.     while (1) {
  64.         if (*s == '\0')
  65.         break;            /* End of line */
  66.         if (instring) {
  67.         if (*s == '>') {
  68.             s++;
  69.             break;        /* End of string */
  70.         }
  71.         } else {
  72.         if ((*s == ',')        /* End of operand */
  73.         || isspace(*s)        /* End of all operands */
  74.         || (*s == ';'))        /* Start of comments */
  75.             break;
  76.         }
  77.         *t++ = *s++;        /* Get a character. */
  78.     }
  79.     *t++ = '\0';
  80.     Heap2Space (t - currarg);    /* Check for space. */
  81.     strcpy (NextFNS, currarg);    /* Store argument. */
  82.     NextFNS += t - currarg;        /* Next available space */
  83.     if (NextFNS > High2)
  84.         High2 = NextFNS;        /* High-water mark */
  85.     narg++;                /* Count arguments. */
  86.     if (*s == ',')
  87.         s++;            /* Skip over separator. */
  88.     }
  89.     return (narg);            /* Successful completion */
  90. }
  91.  
  92.  
  93.  
  94. EffAdr (EA, Bad) register struct OpConfig *EA; int Bad;
  95. /* Adds effective address field to Op (BITSET representing opcode). */
  96. {
  97.     if ((1 << (EA->Mode - 1)) IN Bad) {
  98.     Error (EA->Loc, ModeErr);    /* Invalid mode */
  99.     return;
  100.     } else if (EA->Mode > 12)        /* Special modes */
  101.     return;
  102.     else if (EA->Mode < 8)        /* Register direct or indirect */
  103.     Op |= ((EA->Mode - 1) << 3) | EA->Rn;
  104.     else
  105.     Op |= 0x0038 | (EA->Mode - 8);    /* Absolute modes */
  106.     OperExt (EA);
  107. }
  108.  
  109.  
  110.  
  111. OperExt (EA) register struct OpConfig *EA;
  112. /* Calculate operand Extension word, and check range of operands. */
  113. {
  114.     switch (EA->Mode) {
  115.     case AbsL:
  116.         break;    /* No range checking is needed. */
  117.     case AbsW:
  118.     case ARDisp:
  119.     case PCDisp:
  120.         if ((EA->Value < -32768) || (EA->Value > 32767))
  121.         Error (EA->Loc, SizeErr);
  122.         break;
  123.     case ARDisX:
  124.     case PCDisX:
  125.         if ((EA->Value < -128) || (EA->Value > 127))
  126.         Error (EA->Loc, SizeErr);
  127.         EA->Value &= 0x00FF;            /* Displacement */
  128.         EA->Value |= EA->Xn << 12;            /* Index reg. */
  129.         if (EA->X == Areg)     EA->Value |= 0x8000;    /* Addr. Reg. */
  130.         if (EA->Xsize == Long) EA->Value |= 0x0800;    /* Long reg.  */
  131.         break;
  132.     case Imm:
  133.         if (Size == Word) {
  134.         if ((EA->Value < -32768) || (EA->Value > 65535L))
  135.             Error (EA->Loc, SizeErr);
  136.         } else if (Size == Byte)
  137.         if ((EA->Value < -128) || (EA->Value > 255))
  138.             Error (EA->Loc, SizeErr);
  139.         break;
  140.     }
  141. }
  142.  
  143.  
  144.  
  145. GetOperand (oper, op, pcconv)
  146. char *oper; register struct OpConfig *op; int pcconv;
  147. /* Finds mode and value for source or destination operand.
  148.     If PC-relative addressing is permitted, "pcconv" gives the
  149.     offset to the displacement word; otherwise "pcconv" is zero. */
  150. {
  151.     register char *s, *t;
  152.     register int  i;
  153.     char *opend;
  154.     char UCoper[MAXLINE], tempop[MAXLINE];
  155.     int  rloc;
  156.     long templong;
  157.  
  158.     op->Value  = op->Defn = 0;
  159.     op->Mode   = Null;
  160.     op->X      = X0;
  161.     op->Hunk   = ABSHUNK;
  162.     op->Single = FALSE;
  163.  
  164.     if (*oper == '\0')
  165.     return;                /* There is nothing to process. */
  166.  
  167.     s = oper;
  168.     t = UCoper;
  169.     while (*s) {
  170.     *t++ = toupper (*s);        /* Upper-case version */
  171.     s++;
  172.     }
  173.     *t = '\0';
  174.     opend = s - 1;            /* Last character of operand */
  175.  
  176.     if (*oper == '#') {            /* Immediate */
  177.     s = oper + 1;            /* The value starts here. */
  178.     if (*s == '~')
  179.         s++;            /* Skip over unary NOT. */
  180.     op->Value  = GetValue (s, (op->Loc)+1);
  181.     op->Mode   = Imm;
  182.     op->Hunk   = Hunk2;
  183.     op->Defn   = DefLine2;
  184.     op->Single = SingleFlag;
  185.     if (*(oper+1) == '~') {        /* Unary NOT of entire value */
  186.         if (Hunk2 != ABSHUNK) {
  187.         Error (op->Loc + 2, RelErr);
  188.         op->Hunk = ABSHUNK;    /* Must be absolute! */
  189.         }
  190.         op->Value = ~(op->Value);    /* Flip all bits. */
  191.         if (Size == Byte)
  192.         op->Value &= 0xFFL;    /* Trim to 8 bits. */
  193.         else if (Size == Word)
  194.         op->Value &= 0xFFFFL;    /* Trim to 16 bits. */
  195.     }
  196.     return;
  197.     }
  198.  
  199.     i = IsRegister (oper, opend-oper+1);
  200.     if (i >= 0) {
  201.     op->Mode = (i & 8) ? ARDir : DReg;    /* Register type */
  202.     op->Rn = i & 7;                /* Register number */
  203.     return;
  204.     } else if (i == -2) {
  205.     op->Mode = MultiM;            /* Equated register list */
  206.     op->Value = Sym->Val;
  207.     return;
  208.     } else if ((*oper == '(') && (*opend == ')')) {
  209.     i = IsRegister (oper+1, opend-oper-1);
  210.     if (i >= 8 && i <= 15) {
  211.         op->Mode = ARInd;        /* Address Register indirect */
  212.         op->Rn = i - 8;
  213.         return;
  214.     } else if (i != -1) {
  215.         Error (op->Loc, AddrErr);    /* Data register is invalid! */
  216.         return;
  217.     }    /* else may be parenthesized expression */
  218.     } else if ((*oper == '(')        /* Post-increment */
  219.     && (*opend == '+')
  220.     && (*(opend-1) == ')')) {
  221.     op->Mode = ARPost;
  222.     op->Rn = GetAReg (oper+1, opend-oper-2, op->Loc + 1);
  223.     return;
  224.     } else if ((*oper == '-')        /* Pre-decrement */
  225.     && (*opend == ')')
  226.     && (*(oper+1) == '(')) {
  227.     i = IsRegister (oper+2, opend-oper-2);
  228.     if (i >= 8 && i <= 15) {
  229.         op->Mode = ARPre;
  230.         op->Rn = i - 8;
  231.         return;
  232.     } else if (i > 0) {
  233.         Error (op->Loc, AddrErr);    /* Data register is invalid! */
  234.         return;
  235.     }    /* else parenthesized expression with leading minus? */
  236.     } else if (strcmp (UCoper, "SR") == 0) {
  237.     op->Mode = SR;                /* Status Register */
  238.     return;
  239.     } else if (strcmp (UCoper, "CCR") == 0) {
  240.     op->Mode = CCR;            /* Condition Code Register */
  241.     return;
  242.     } else if (strcmp (UCoper, "USP") == 0) {
  243.     op->Mode = USP;            /* User Stack Pointer */
  244.     return;
  245.     }
  246.  
  247.     /* Try to split off displacement (if present).
  248.     We'll assume we have a register expression if the operand
  249.     ends with a parenthesized expression not preceded by an
  250.     operator.  I know this code is a real kludge, but that's
  251.     the result of the bloody syntax.  Thanks, Motorola.    */
  252.  
  253.     s = opend;                /* Last character */
  254.     if (i = (*s == ')'))        /* Trailing parenthesis? */
  255.     while (*(--s) != '(')        /* Find left parenthesis. */
  256.         if (s <= oper)
  257.         break;
  258.     if (s <= oper)            /* Must not be at beginning. */
  259.     i = FALSE;
  260.     if (i) {
  261.     if (s == (oper+1)) {
  262.         if (*oper == '-')
  263.         i = FALSE;        /* Leading minus sign */
  264.     } else {
  265.         t = s - 1;
  266.         if (*t == '*') {        /* Location counter? */
  267.         t--;
  268.         if (!IsOperator (t) || (*t == ')'))
  269.             i = FALSE;        /* No, it's multiplication. */
  270.         } else if (IsOperator (t) && (*t != ')')) {
  271.         i = FALSE;        /* Preceded by an operator */
  272.         }
  273.     }
  274.     }
  275.  
  276.     if (i) {        /* Looks like a displacement mode */
  277.     *s = '\0';
  278.     op->Value = GetValue (oper, op->Loc);    /* Displacement */
  279.     op->Hunk  = Hunk2;            /* Hunk number */
  280.     op->Defn  = DefLine2;            /* Line where defined */
  281.     *s++ = '(';                /* Restore parenthesis. */
  282.  
  283.     rloc = op->Loc + s - oper;    /* The register starts here. */
  284.     s = GetField (s, tempop);    /* Get address register. */
  285.     if (*s == '\0')            /* If there's no index register, */
  286.         tempop[strlen(tempop)-1] = '\0';    /* chop off parenthesis. */
  287.  
  288.     if ((tempop[2] == '\0')
  289.     && (toupper (tempop[0]) == 'P')
  290.     && (toupper (tempop[1]) == 'C')) {
  291.         op->Mode = PCDisp;            /* Program Counter */
  292.         if (op->Hunk == CurrHunk) {
  293.         op->Value -= (AddrCnt+pcconv);    /* Adjust displacement. */
  294.         op->Hunk = ABSHUNK;
  295.         }
  296.     } else {
  297.         if ((op->Value == 0)    /* If displacement is zero   */
  298.         && (op->Hunk == ABSHUNK)    /*  and is absolute          */
  299.         && (op->Defn < LineCount)    /*  and is already defined   */
  300.         && !(OpM68R IN AdrModeA)    /*  and isn't for a MOVEP    */
  301.         && !NoOpt)            /*  and we can optimize      */
  302.         op->Mode = ARInd;    /*  forget the displacement. */
  303.         else
  304.         op->Mode = ARDisp;    /* Address reg. w/displacement */
  305.         op->Rn = GetAReg (tempop, strlen (tempop), rloc);
  306.     }
  307.     if (*s != '\0') {        /* Index register is present. */
  308.         if (op->Mode == PCDisp)
  309.         op->Mode = PCDisX;    /* Program Counter indexed */
  310.         else
  311.         op->Mode = ARDisX;    /* Address Register indexed */
  312.         if (*s != ',')
  313.         Error (op->Loc, AddrErr);    /* Bad separator */
  314.         s++;                /* Skip separator. */
  315.         rloc = op->Loc + s - oper;        /* Start of index */
  316.         s = GetField (s, tempop);        /* Get index register. */
  317.         t = tempop + strlen(tempop);
  318.         if (*s == '\0')
  319.         *(--t) = '\0';            /* Chop parenthesis. */
  320.         else
  321.         Error (rloc, AddrErr);        /* It better be there. */
  322.  
  323.         t -= 2;
  324.         if ((t < tempop) || (*t != '.')) {
  325.         op->Xsize = Word;    /* Size defaults to 16 bits. */
  326.         t += 3;
  327.         } else {
  328.         *t++ = '\0';            /* Chop off size code. */
  329.         switch (toupper (*t)) {
  330.         case 'W':            /* Word */
  331.             op->Xsize = Word;
  332.             break;
  333.         case 'L':            /* Long */
  334.             op->Xsize = Long;
  335.             break;
  336.         default:
  337.             Error (op->Loc+s-1-oper, SizeErr);    /* Invalid size */
  338.             op->Xsize = Word;        /* Make it word for now. */
  339.         }
  340.         }
  341.         i = IsRegister (tempop,t-tempop-1);    /* Get register. */
  342.         op->Xn = i & 7;            /* Index register number */
  343.         if ((i >= 0) && (i <= 7))
  344.         op->X = Dreg;            /* Data Register */
  345.         else if ((i >= 8) && (i <= 15))
  346.         op->X = Areg;            /* Address Register */
  347.         else
  348.         Error (rloc, AddrErr);        /* Invalid register */
  349.     }
  350.  
  351.     if ((op->Hunk >= 0) && (op->Hunk != ABSHUNK))
  352.         Error (op->Loc, RelErr);    /*  Relocatable displacement */
  353.     return;
  354.     }
  355.  
  356.     if ((i = GetMultReg (oper, op->Loc)) != 0) {
  357.     op->Value = (long) i;
  358.     op->Mode = MultiM;        /* Register list for MOVEM */
  359.     return;
  360.     }
  361.  
  362.     if ((*oper == '(')        /* Operands of the form (xxxx).W or (xxxx).L */
  363.     && (*(opend-2) == ')')
  364.     && (*(opend-1) == '.')
  365.     && ((toupper(*opend) == 'W') || (toupper(*opend) == 'L'))) {
  366.     *(opend-1) = '\0';    /* Temporarily cut off length specifier. */
  367.     op->Value  = GetValue (oper, op->Loc);    /* Get operand value. */
  368.     op->Hunk   = Hunk2;
  369.     op->Defn   = DefLine2;
  370.     op->Single = SingleFlag;
  371.     if (toupper(*opend) == 'W')
  372.         op->Mode = AbsW;    /* Absolute word */
  373.     else
  374.         op->Mode = AbsL;    /* Absolute long */
  375.     *(opend-1) = '.';    /* Restore original operand. */
  376.     return;
  377.     }
  378.  
  379.     op->Value  = GetValue (oper, op->Loc);    /* Plain old expression */
  380.     op->Hunk   = Hunk2;
  381.     op->Defn   = DefLine2;
  382.     op->Single = SingleFlag;
  383.     op->Mode   = AbsL;        /* Assume absolute long addressing. */
  384.  
  385.     if (NoOpt)
  386.     return;            /* Do no optimizing. */
  387.  
  388.     if (DefLine2 < LineCount) {        /* Backward reference */
  389.  
  390.     if (Hunk2 < 0) {
  391.         return;        /* External - leave as absolute long. */
  392.  
  393.     } else if (Hunk2 == CurrHunk) {    /* Reference to current hunk */
  394.         if (pcconv) {
  395.         templong = op->Value-(AddrCnt+pcconv);    /* PC disp. */
  396.         if ((templong >= -32768) && (templong <= 32767)) {
  397.             op->Mode = PCDisp;    /* Convert to PC relative mode. */
  398.             op->Value=templong;    /* Adjust displacement. */
  399.             op->Hunk = ABSHUNK;
  400.         }
  401.         }
  402.  
  403.     } else if (Hunk2 == ABSHUNK) {    /* Absolute value */
  404.         if ((op->Value >= -32768) && (op->Value <= 32767))
  405.         op->Mode = AbsW;    /* Absolute word */
  406.  
  407.     } else if ((SmallData != -1)
  408.     && (op->Value>=0) && (op->Value<=65535L)) {
  409.         op->Mode = ARDisp;        /* Make it a data reference     */
  410.         op->Rn = SmallData;        /*  through specified register. */
  411.         op->Value -= 32768L;    /* Adjust displacement. */
  412.         op->Hunk = ABSHUNK;
  413.     }
  414.     return;            /* Could default to absolute long. */
  415.  
  416.     } else if (SmallData==-1) {    /* Fwd. reference - if not small data, */
  417.     return;            /*  leave as absolute long addressing. */
  418.  
  419.     } else if (Brnch IN AdrModeA) {
  420.     return;            /* Branches are handled elsewhere. */
  421.  
  422.     } else if (!Pass2) {    /* Forward reference, pass 1 */
  423.     op->Mode = ARDisp;    /* Assume displacement       */
  424.     op->Rn = SmallData;    /*  from specified register. */
  425.     op->Hunk = ABSHUNK;
  426.     return;
  427.  
  428.     } else {            /* On pass 2 we know what it is. */
  429.  
  430.     if (Hunk2 < 0) {
  431.         Error (op->Loc,FwdRef);    /* External - must be 32 bits. */
  432.         op->Mode = AbsW;        /* Force absolute word anyway. */
  433.  
  434.     } else if (Hunk2 == CurrHunk) {    /* It's in the current hunk. */
  435.         op->Mode = PCDisp;        /* Convert to PC relative mode. */
  436.         op->Value -= AddrCnt + pcconv;    /* Adjust displacement. */
  437.         op->Hunk = ABSHUNK;
  438.         if (!pcconv || (op->Value < -32768) || (op->Value > 32767))
  439.         Error (op->Loc,FwdRef);    /* It doesn't fit! */
  440.  
  441.     } else if (Hunk2 == ABSHUNK) {    /* It's absolute. */
  442.         op->Mode = AbsW;        /* It has to fit in a word. */
  443.         if ((op->Value < -32768) || (op->Value > 32767))
  444.         Error (op->Loc,FwdRef);    /* It doesn't fit! */
  445.  
  446.     } else {
  447.         op->Mode = ARDisp;        /* Assume data reference        */
  448.         op->Rn = SmallData;        /*  through specified register. */
  449.         op->Value -= 32768L;    /* Adjust displacement. */
  450.         if ((op->Value < -32768) || (op->Value > 32767))
  451.         Error (op->Loc,FwdRef);    /* It doesn't fit! */
  452.     }
  453.     }
  454. }
  455.  
  456.  
  457.  
  458. int GetMultReg (oper, loc) char *oper; int loc;
  459. /* Builds a register mask for the MOVEM instruction.
  460.     Returns the mask in the low-order portion of its value if
  461.     "oper" is a valid multiple-register list; otherwise returns 0. */
  462. {
  463.     register char *s, *t;
  464.     register int  j;
  465.     int t1, t2;        /* Temporary variables for registers */
  466.     int range;        /* We're processing a range of registers. */
  467.     int multext;    /* The result is built here. */
  468.  
  469.     multext = 0;
  470.     range = FALSE;
  471.     s = oper;
  472.     if (IsOperator (s))
  473.     return (0);            /* Starts with an operator! */
  474.  
  475.     while (1) {
  476.     for (t = s; *t; t++) {
  477.         if ((*t == '-') || (*t == '/')) {
  478.         break;
  479.         }
  480.     }
  481.     if ((multext == 0) && (*t == '\0'))
  482.         return (0);            /* Reject single term. */
  483.     if ((t2 = IsRegister (s, t-s)) < 0)
  484.         return (0);            /* Not a recognizable register */
  485.  
  486.     if (!range) {
  487.         multext |= (1 << t2);    /* Single register */
  488.         t1 = t2;            /* Save number in case it's a range. */
  489.     } else {            /* Range of registers */
  490.         range = FALSE;
  491.         if (t1 > t2) {
  492.         j = t1;            /* Swap registers if backwards. */
  493.         t1 = t2;
  494.         t2 = j;
  495.         }
  496.         for (j = t1; j <= t2; j++)
  497.         multext |= (1 << j);    /* Mark all registers in range. */
  498.         if (*t == '-')
  499.         return (0);        /* Invalid range */
  500.     }
  501.     if (*t == '\0')
  502.         break;            /* Normal end of operand */
  503.     if (*t++ == '-')
  504.         range = TRUE;        /* Range indicator */
  505.     if (*t == '\0')
  506.         return (0);            /* Premature end of operand */
  507.     s = t;
  508.     }
  509.     return (multext);
  510. }
  511.  
  512.  
  513.  
  514. int GetAReg (op, len, loc) char *op; int len, loc;
  515. /* Validate an address register specification.
  516.     Valid specifications are A0 through A7, SP, or an EQUR label.
  517.     The address register number will be returned if it is valid.
  518.     Otherwise, Error will be called, using "loc" for the error
  519.     location (this is its only use), and zero (A0) will be returned. */
  520. {
  521.     register int i;
  522.  
  523.     i = IsRegister (op, len);        /* Get register number. */
  524.     if ((i >= 8) && (i <= 15))
  525.     return (i - 8);            /* Valid address register */
  526.     else {
  527.     Error (loc, AddrErr);        /* Not an address register */
  528.     return (0);            /* Set to A0. */
  529.     }
  530. }
  531.  
  532.  
  533.  
  534. int IsRegister (op, len) char *op; int len;
  535. /* Check whether the current operand is an address or data register.
  536.     Valid specifications are D0 through D7, A0 through A7, SP,
  537.     or any symbol equated to a register with the EQUR directive.
  538.     Return values:
  539.     0 through 7 - data registers 0 through 7 respectively
  540.     8 through 15 - address registers 0 through 7 respectively
  541.     -1 - not a recognizable register
  542.     -2 - Equated register list for MOVEM instruction (REG) */
  543. {
  544.     char tempop[MAXLINE];
  545.     register char *s;
  546.     register int  i;
  547.  
  548.     if (len == 2) {        /* Two-character specification */
  549.     i = toupper (*op);
  550.     s = op + 1;
  551.     if ((i == 'S') && (toupper (*s) == 'P')) {
  552.         return (15);        /* Stack Pointer */
  553.     } else if ((*s >= '0') && (*s <= '7')) {
  554.         if (i == 'A') {
  555.         return (*s - '0' + 8);    /* Address Register */
  556.         } else if (i == 'D') {
  557.         return (*s - '0');    /* Data Register */
  558.         }
  559.     }
  560.     }
  561.     if (!GotEqur)            /* If we have no EQURs to check */
  562.     return (-1);            /*  don't waste any time here.  */
  563.     for (i = 0, s = op; i < len; i++) {
  564.     if (IsOperator (s))
  565.         return (-1);        /* It sure isn't a label. */
  566.     tempop[i] = *s++;
  567.     }
  568.     tempop[i] = '\0';
  569.     if (ReadSymTab (tempop)) {
  570.     if (Sym->Flags & 0x60) {
  571.         AddRef (LineCount);        /* Found a register or list. */
  572.         return ((Sym->Flags & 0x20) ? (int) Sym->Val : -2);
  573.     }
  574.     }
  575.     return (-1);            /* Not a recognizable register */
  576. }
  577.  
  578.  
  579.  
  580. int GetInstModeSize (Mode) register int Mode;
  581. /* Determines the size for the various instruction modes. */
  582. {
  583.     switch (Mode) {
  584.     case ARDisp:
  585.     case ARDisX:
  586.     case PCDisp:
  587.     case PCDisX:
  588.     case AbsW:
  589.         return (2);
  590.     case AbsL:
  591.         return (4);
  592.     case MultiM:
  593.         return (0);        /* Accounted for by code generator */
  594.     case Imm:
  595.         if (Size == Long)
  596.         return (4);
  597.         else
  598.         return (2);
  599.     default:
  600.         return (0);
  601.     }
  602. }
  603.